<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script>
    function imageShapeRect(elementId)
    {
        var s = document.getElementById("image-shape").getBoundingClientRect();
        var r = document.getElementById(elementId).getBoundingClientRect();
        return {left: r.left - s.left, top: r.top - s.top, width: r.width, height: r.height};
    }

    window.onload = function() {
      var quiet = true; // PASS output depends on if subpixel layout has been enabled

      shouldBe("imageShapeRect('a').top", "0");
      shouldBeCloseTo("imageShapeRect('a').left", 292, 1, quiet);

      shouldBe("imageShapeRect('b').top", "50");
      shouldBe("imageShapeRect('b').left", "300");

      shouldBe("imageShapeRect('c').top", "75");
      shouldBe("imageShapeRect('c').left", "300");

      shouldBe("imageShapeRect('d').top", "125");
      shouldBeCloseTo("imageShapeRect('d').left", 292, 1, quiet);

      shouldBe("imageShapeRect('e').top", "150");
      shouldBe("imageShapeRect('e').left", "0");
    };
</script>
<style>
    #image-shape {
        float: left;
        shape-outside: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='250px' height='100px'><rect x='50' y='50' width='200' height='50' fill='blue'/></svg>");
        shape-margin: 50px;
        shape-image-threshold: 0;
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><rect x='0' y='0' width='300' height='150' rx='50' ry='50' fill='blue'/></svg>");
        background-repeat: no-repeat;
        width: 350px;
        height: 250px;
    }

    #content {
        font: 25px/1 Ahem, sans-serif;
        color: green;
    }
</style>
</head>
<body>
  <p>This test requires the Ahem font. The green content should wrap around the blue rounded rectangle.</p>
  <div id="content" style="position: relative">
      <div id="image-shape"></div>
      <span id="a">X</span><br><br><span id="b">X</span><br><span id="c">X</span><br><br><span id="d">X</span><br><span id="e">XXXX</span>
  </div>
  <div id="console"></div>
</body>
</html>
